package com.lcw.framework.util;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

public class FileUploadUtil {
	public static Boolean uploadFile(HttpServletRequest request, CommonsMultipartFile file) {  
        System.out.println("开始");  
        String path = request.getSession().getServletContext().getRealPath("upload");  
        String fileName = file.getOriginalFilename();  
        System.out.println(path);  
        File targetFile = new File("C:\\", fileName);  
        if (!targetFile.exists()) {  
            targetFile.mkdirs();  
        }  
        // 保存  
        try {  
            file.transferTo(targetFile);  
            return true;  
        } catch (Exception e) {  
            e.printStackTrace();  
            return false;  
        }  
 
   }  
}
